#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 105;
int dp[maxn],n,high[maxn],f[maxn];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>high[i];
	}
	dp[1]=1;
	
	for(int i=2;i<=n;i++){
    	for(int j=1;j<i;j++){
           if(high[j]<high[i])	dp[i]=max(dp[i],dp[j]);
       }
       dp[i]++;
	}
	f[n]=1;
	for(int i=n-1;i>=1;i--){
		for(int j=i+1;j<=n;j++){
			if(high[j]<high[i]) f[i]=max(f[i],f[j]);
		}
		f[i]++;
	} 
	
	int ans=0;
	for(int i=1;i<=n;i++){
		dp[i]=dp[i]+f[i]-1;
		ans = max(ans,dp[i]);
	}
	cout<<n-ans<<endl;
	return 0;
}
